<?php

/*--------------------------------------------------------------------------/
* @Author		KulerThemes.com http://www.kulerthemes.com
* @Copyright	Copyright (C) 2012 - 2013 KulerThemes.com. All rights reserved.
* @License		KulerThemes.com Proprietary License
/---------------------------------------------------------------------------*/

?>

<?php echo $header; ?>
<?php if (isset($ksb_building_mode)) { ?>
    <style type="text/css">
        #header, .breadcrumb, .box > .heading .buttons,.vtabs, #footer {
            display: none !important;
        }

        #content {
            padding: 0 !important;
        }

        .box > .content {
            background: none !important;
        }

        .vtabs-content {
            padding-left: 15px !important;
        }
    </style>
<?php } ?>
    <script type="text/javascript">
        <?php if (isset($ksb_updated_module)) { ?>
        var ksb_updated_module = <?php echo $ksb_updated_module; ?>;
        <?php } ?>
    </script>
    <div id="content" class="kuler-module">
    <div class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
            <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
        <?php } ?>
    </div>
    <?php if ($error_warning) { ?>
        <div class="warning"><?php echo $error_warning; ?></div>
    <?php } ?>
    <div class="box">
    <div class="heading clearafter">
        <h1><img src="./view/kulercore/images/logos/kuler_slides.png" alt="<?php echo $heading_title; ?>" /></h1>
        <div class="buttons">
            <a onclick="$('#form').submit();" class="button save-settings"><?php echo $button_save; ?></a>
            <a onclick="$('#op').val('close'); $('#form').submit();" class="button cancel-settings"><?php echo $button_close; ?></a>
            <a href="<?php echo $cancel; ?>" class="button cancel-settings"><?php echo $button_cancel; ?></a>
        </div>
    </div>
    <div class="content">
    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
    <input type="hidden" name="tab" id="tab" value="<?php if (isset($tab)) echo $tab ?>" />
    <input type="hidden" name="op" id="op" />

    <div style="margin: 20px 0 0 30px;">
        <label><?php echo $__['entry_store']; ?></label>
        <select name="store_id" id="StoreSelector">
            <?php foreach ($stores as $store_id => $store_name) { ?>
                <option value="<?php echo $store_id; ?>"<?php if ($store_id == $selected_store_id) echo ' selected="selected"'; ?>><?php echo $store_name; ?></option>
            <?php } ?>
        </select>
    </div>

    <!-- block: vtab -->
    <ul class="vtabs">
        <?php $module_row = 1; ?>
        <?php $module_count = array(); ?>
        <?php foreach ($modules as $module) { ?>
            <li>
                <a href="#tab-module-<?php echo $module_row; ?>" id="module-<?php echo $module_row; ?>">
                    <?php echo $module['main_title']; ?>
                    <img class="remove-element" src="view/kulercore/images/icons/icon-delete.png" alt="" onclick="$('.vtabs a:first').trigger('click'); $('#module-<?php echo $module_row; ?>').remove(); $('#tab-module-<?php echo $module_row; ?>').remove(); return false;" />
                </a>
            </li>
            <?php $module_row++; ?>
        <?php } ?>
        <li><span class="module-add"><?php echo $button_add_module; ?>&nbsp;<img class="add-element" src="view/kulercore/images/icons/icon-add.png" alt="" onclick="addModule();" /></span></li>
    </ul>
    <!-- block: modules -->
    <?php $module_row = 1; ?>
    <?php foreach ($modules as $module) { ?>
        <?php $module_title = isset($module['module_title']) && $module['module_title'] ? $module['module_title'] : $text_prefix . ' ' . $module_row ?>
        <div id="tab-module-<?php echo $module_row; ?>" class="vtabs-content">
        <table class="form">
            <tr>
                <td><?php echo $entry_status; ?></td>
                <td width="10">
                    <div class="kuler-switch-btn">
                        <input type='hidden' name='kuler_slides_module[<?php echo $module_row; ?>][status]' value='0' />
                        <input type="checkbox" name="kuler_slides_module[<?php echo $module_row; ?>][status]"<?php echo $module['status'] ? ' checked="checked"' : '' ?>  value="1">
                        <span class="kuler-switch-btn-holder"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <td><?php echo $entry_showtitle; ?></td>
                <td width="10">
                    <div class="kuler-switch-btn">
                        <input type='hidden' name='kuler_slides_module[<?php echo $module_row; ?>][show_title]' value='0' />
                        <input type="checkbox" name="kuler_slides_module[<?php echo $module_row; ?>][show_title]"<?php echo $module['show_title'] ? ' checked="checked"' : '' ?>  value="1">
                        <span class="kuler-switch-btn-holder"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <td><?php echo $entry_module; ?></td>
                <td>
                    <?php foreach ($languages as $language) { ?>
                        <p>
                            <input type="text" name="kuler_slides_module[<?php echo $module_row; ?>][module_title][<?php echo $language['language_id']; ?>]" value="<?php echo $module['module_title'][$language['language_id']]; ?>"<?php if ($language['language_id'] == $config_admin_language_id) { ?> class="ModuleTitle" data-shortcode="#ModuleShortCode_<?php echo $module_row; ?>"<?php } ?> />
                            <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" />
                        </p>
                    <?php } ?>
                </td>
            </tr>
	        <tr>
		        <td><?php echo $entry_shortcode; ?></td>
		        <td>
			        <input type="text" id="ModuleShortCode_<?php echo $module_row; ?>" class="ModuleShortCode" name="kuler_slides_module[<?php echo $module_row; ?>][shortcode]" value="<?php if (isset($module['shortcode'])) echo $module['shortcode']; ?>" readonly="readonly" size="40" />
		        </td>
	        </tr>
            <tr>
                <td><?php echo $entry_layout; ?></td>
                <td><select name="kuler_slides_module[<?php echo $module_row; ?>][layout_id]">
                        <?php foreach ($layouts as $layout) { ?>
                            <?php if ($layout['layout_id'] == $module['layout_id']) { ?>
                                <option value="<?php echo $layout['layout_id']; ?>" selected="selected"><?php echo $layout['name']; ?></option>
                            <?php } else { ?>
                                <option value="<?php echo $layout['layout_id']; ?>"><?php echo $layout['name']; ?></option>
                            <?php } ?>
                        <?php } ?>
                    </select></td>
            </tr>
            <tr>
                <td><?php echo $entry_position; ?></td>
                <td><select name="kuler_slides_module[<?php echo $module_row; ?>][position]">
                        <?php if ($module['position'] == 'content_top') { ?>
                            <option value="content_top" selected="selected"><?php echo $text_content_top; ?></option>
                        <?php } else { ?>
                            <option value="content_top"><?php echo $text_content_top; ?></option>
                        <?php } ?>
                        <?php if ($module['position'] == 'content_bottom') { ?>
                            <option value="content_bottom" selected="selected"><?php echo $text_content_bottom; ?></option>
                        <?php } else { ?>
                            <option value="content_bottom"><?php echo $text_content_bottom; ?></option>
                        <?php } ?>
                        <?php if ($module['position'] == 'column_left') { ?>
                            <option value="column_left" selected="selected"><?php echo $text_column_left; ?></option>
                        <?php } else { ?>
                            <option value="column_left"><?php echo $text_column_left; ?></option>
                        <?php } ?>
                        <?php if ($module['position'] == 'column_right') { ?>
                            <option value="column_right" selected="selected"><?php echo $text_column_right; ?></option>
                        <?php } else { ?>
                            <option value="column_right"><?php echo $text_column_right; ?></option>
                        <?php } ?>
                    </select></td>
            </tr>
            <tr>
                <td><?php echo $entry_sort_order; ?></td>
                <td><input type="text" name="kuler_slides_module[<?php echo $module_row; ?>][sort_order]" value="<?php echo $module['sort_order']; ?>" size="3" /></td>
            </tr>
        </table>
        <!-- block: module vtab list -->
        <?php $tab_row = 1 ?>
        <?php $module_count[$module_row] = $tab_row ?>
        <?php foreach($module['tabs'] as $tab) : ?>
            <?php $tab_key = $module_row . '-' . $tab_row ?>
            <div id="tab-content-<?php echo $tab_key ?>" class="tab-<?php echo $tab['tab_type']?>">
                <table class="form">
                    <tr>
                        <td><?php echo $entry_tab_type; ?></td>
                        <td><select name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][tab_type]" onchange="changeTabType(this,<?php echo $module_row, ',' , $tab_row ?>)">
                                <option value="category"<?php echo ($tab['tab_type'] == 'category' ? ' selected="selected"' : '') ?>><?php echo $text_category ?></option>
                                <option value="product"<?php echo ($tab['tab_type'] == 'product' ? ' selected="selected"' : '') ?>><?php echo $text_featured ?></option>
                                <option value="bestseller"<?php echo ($tab['tab_type'] == 'bestseller' ? ' selected="selected"' : '') ?>><?php echo $text_bestseller ?></option>
                                <option value="latest"<?php echo ($tab['tab_type'] == 'latest' ? ' selected="selected"' : '') ?>><?php echo $text_latest ?></option>
                                <option value="special"<?php echo ($tab['tab_type'] == 'special' ? ' selected="selected"' : '') ?>><?php echo $text_special ?></option>
                            </select></td>
                    </tr>
                    <tr class="event-category" id="cate-<?php echo $tab_key ?>">
                        <td><?php echo $entry_category; ?></td>
                        <td>
                            <select name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][category_id]">
                                <?php foreach ($categories as $category) : ?>
                                    <?php if ($category['category_id'] == $tab['category_id']) : ?>
                                        <option value="<?php echo $category['category_id']; ?>" selected="selected"><?php echo $category['name']; ?></option>
                                    <?php else : ?>
                                        <option value="<?php echo $category['category_id']; ?>"><?php echo $category['name']; ?></option>
                                    <?php endif ?>
                                <?php endforeach ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="event-product" id="product-<?php echo $tab_key ?>">
                        <td><?php echo $entry_product; ?></td>
                        <td><input type="text" value="" size="40" data-row="<?php echo $module_row ?>" data-tab="<?php echo $tab_row ?>" /></td>
                    </tr>
                    <tr class="event-product-list" id="product-list-<?php echo $tab_key ?>">
                        <td>&nbsp;</td>
                        <td>
                            <div id="event-product-<?php echo $tab_key ?>" class="scrollbox">
                                <?php if(isset($tab['list']) && is_array($tab['list'])) : ?>
                                    <?php $class = 'odd'; ?>
                                    <?php foreach ($tab['list'] as $product) : ?>
                                        <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                                        <div id="event-product-<?php echo $tab_key, '-',$product['product_id']; ?>" class="<?php echo $class; ?>"><?php echo $product['name']; ?> <img src="view/kulercore/images/icons/icon-delete.png" data-row="<?php echo $tab_key ?>" />
                                            <input type="hidden" value="<?php echo $product['product_id']; ?>" />
                                        </div>
                                    <?php endforeach ?>
                                <?php endif ?>
                            </div>
                            <input type="hidden" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][products]" value="<?php echo $tab['products'] ?>" /></td>
                    </tr>
                    <tr class="event-limit">
                        <td><?php echo $entry_item; ?></td>
                        <td><input type="text" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][item]" value="<?php echo $tab['item']; ?>" size="3" />
                            <?php if (isset($error_item[$module_row][$tab_row])) : ?>
                                <span class="error"><?php echo $error_item[$module_row][$tab_row]; ?></span>
                            <?php endif ?>
                        </td>
                    </tr>
                    <tr>
                        <td><?php echo $entry_limit; ?></td>
                        <td>
                            <input type="text" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][limit]" value="<?php echo $tab['limit']; ?>" size="3" />
                            <?php if (isset($error_limit[$module_row][$tab_row])) : ?>
                                <span class="error"><?php echo $error_limit[$module_row][$tab_row]; ?></span>
                            <?php endif ?>
                        </td>
                    </tr>
                    <tr>
                        <td><?php echo $entry_dimension; ?></td>
                        <td>
                            <input type="text" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][image_width]" value="<?php echo $tab['image_width']; ?>" size="5" placeholder="width" />
                            <input type="text" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][image_height]" value="<?php echo $tab['image_height']; ?>" size="5" placeholder="height" />
                            <?php if (isset($error_dimension[$module_row][$tab_row])) : ?>
                                <span class="error"><?php echo $error_dimension[$module_row][$tab_row]; ?></span>
                            <?php endif ?>
                        </td>
                    </tr>
                    <tr>
                        <td>Product Name</td>
                        <td width="10">
                            <div class="kuler-switch-btn">
                                <input type='hidden' name='kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][name]' value='0' />
                                <input type="checkbox" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][name]"<?php echo $tab['name'] ? ' checked="checked"' : '' ?>  value="1">
                                <span class="kuler-switch-btn-holder"></span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>Product Price</td>
                        <td width="10">
                            <div class="kuler-switch-btn">
                                <input type='hidden' name='kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][price]' value='0' />
                                <input type="checkbox" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][price]"<?php echo $tab['price'] ? ' checked="checked"' : '' ?>  value="1">
                                <span class="kuler-switch-btn-holder"></span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>Product Rating</td>
                        <td width="10">
                            <div class="kuler-switch-btn">
                                <input type='hidden' name='kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][rating]' value='0' />
                                <input type="checkbox" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][rating]"<?php echo $tab['rating'] ? ' checked="checked"' : '' ?>  value="1">
                                <span class="kuler-switch-btn-holder"></span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>Product Description</td>
                        <td width="10">
                            <div class="kuler-switch-btn">
                                <input type='hidden' name='kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][description]' value='0' />
                                <input type="checkbox" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][description]"<?php echo $tab['description'] ? ' checked="checked"' : '' ?>  value="1">
                                <span class="kuler-switch-btn-holder"></span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>Product Add to Card</td>
                        <td width="10">
                            <div class="kuler-switch-btn">
                                <input type='hidden' name='kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][add]' value='0' />
                                <input type="checkbox" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][add]"<?php echo $tab['add'] ? ' checked="checked"' : '' ?>  value="1">
                                <span class="kuler-switch-btn-holder"></span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>Product Wishlist</td>
                        <td width="10">
                            <div class="kuler-switch-btn">
                                <input type='hidden' name='kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][wishlist]' value='0' />
                                <input type="checkbox" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][wishlist]"<?php echo $tab['wishlist'] ? ' checked="checked"' : '' ?>  value="1">
                                <span class="kuler-switch-btn-holder"></span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>Product Compare</td>
                        <td width="10">
                            <div class="kuler-switch-btn">
                                <input type='hidden' name='kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][compare]' value='0' />
                                <input type="checkbox" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][compare]"<?php echo $tab['compare'] ? ' checked="checked"' : '' ?>  value="1">
                                <span class="kuler-switch-btn-holder"></span>
                            </div>
                        </td>
                    </tr>
	                <tr>
		                <td>Product Description Limit:</td>
		                <td>
			                <input type="text" name="kuler_slides_module[<?php echo $module_row; ?>][tabs][<?php echo $tab_row ?>][description_limit]" value="<?php if (isset($tab['description_limit'])) echo $tab['description_limit']; ?>" size="5" />
		                </td>
	                </tr>
                </table>
            </div>
            <?php $tab_row++ ?>
        <?php endforeach ?>
        </div>
        <?php $module_row++; ?>
    <?php } ?>
    </form>
    </div>
    </div>
    </div>
    <script type="text/javascript"><!--
    var saveUrl = '<?php echo $action; ?>';
    saveUrl = saveUrl.replace(new RegExp('&amp;', 'g'), '&');
    $('#StoreSelector').on('change', function () {
        window.location = saveUrl + '&store_id=' + $(this).val();
    });

    var module_row = <?php echo $module_row; ?>;
    var module_count = <?php echo count($module_count) ? json_encode($module_count) : '{}'; ?>;
    function addModule() {
        var tab_row = 1;
        var tab_key = module_row + '-' + tab_row;
        html  = '<div id="tab-module-' + module_row + '" class="vtabs-content">';
        html += '  <table class="form">';

        html += '    <tr>';
        html += '      <td><?php echo $entry_status; ?></td>';
        html += '      <td width="10"><div class="kuler-switch-btn">';
        html += '        <input type="hidden" name="kuler_slides_module[' + module_row + '][status]" value="0" />';
        html += '        <input type="checkbox" name="kuler_slides_module[' + module_row + '][status]" value="1" checked="checked" />';
        html += '        <span class="kuler-switch-btn-holder"></span></div></td>';
        html += '    </tr>';

        html += '      <td><?php echo $entry_showtitle; ?></td>';
        html += '      <td width="10"><div class="kuler-switch-btn">';
        html += '        <input type="hidden" name="kuler_slides_module[' + module_row + '][show_title]" value="0" />';
        html += '        <input type="checkbox" name="kuler_slides_module[' + module_row + '][show_title]" value="1" checked="checked" />';
        html += '        <span class="kuler-switch-btn-holder"></span></div></td>';
        html += '    </tr>';

        html += '    <tr>';
        html += '        <td><?php echo $entry_module; ?></td>';
        html += '        <td>';
        html += '            <?php foreach ($languages as $language) { ?>';
        html += '                <p>';
        html += '                    <input type="text" name="kuler_slides_module['+ module_row +'][module_title][<?php echo $language['language_id']; ?>]"<?php if ($language['language_id'] == $config_admin_language_id) { ?> class="ModuleTitle" data-shortcode="#ModuleShortCode_'+ module_row +'"<?php } ?> />';
        html += '                    <img src="view/image/flags/<?php echo $language['image']; ?>" title="' + <?php echo $this->jsEncode($language['name']); ?> + '" />';
        html += '                </p>';
        html += '            <?php } ?>';
        html += '        </td>';
        html += '    </tr>';

	    html += '    <tr>';
	    html += '        <td><?php echo $entry_shortcode; ?></td>';
	    html += '        <td>';
	    html += '            <input type="text" id="ModuleShortCode_'+ module_row +'" class="ModuleShortCode" name="kuler_slides_module['+ module_row +'][shortcode]" readonly="readonly" size="40" />';
	    html += '        </td>';
	    html += '    </tr>';

        html += '    <tr>';
        html += '      <td><?php echo $entry_layout; ?></td>';
        html += '      <td><select name="kuler_slides_module[' + module_row + '][layout_id]">';
        <?php foreach ($layouts as $layout) { ?>
        html += '           <option value="<?php echo $layout['layout_id']; ?>">' + <?php echo $this->jsEncode($layout['name']); ?>+ ' </option>';
        <?php } ?>
        html += '      </select></td>';
        html += '    </tr>';
        html += '    <tr>';
        html += '      <td><?php echo $entry_position; ?></td>';
        html += '      <td><select name="kuler_slides_module[' + module_row + '][position]">';
        html += '        <option value="content_top"><?php echo $text_content_top; ?></option>';
        html += '        <option value="content_bottom"><?php echo $text_content_bottom; ?></option>';
        html += '        <option value="column_left"><?php echo $text_column_left; ?></option>';
        html += '        <option value="column_right"><?php echo $text_column_right; ?></option>';
        html += '      </select></td>';
        html += '    </tr>';
        html += '    <tr>';

        html += '    <tr>';
        html += '      <td><?php echo $entry_sort_order; ?></td>';
        html += '      <td><input type="text" name="kuler_slides_module[' + module_row + '][sort_order]" value="" size="3" /></td>';
        html += '    </tr>';
        html += '  </table>';

        html += '  <div id="tab-main-' + module_row + '">';
        html += '  <table class="form">';
        html += '    <tr>';
        html += '      <td><?php echo $entry_tab_type; ?></td>';
        html += '      <td><select name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][tab_type]" onchange="changeTabType(this,' + module_row + ',' + tab_row + ')">';
        html += '        <option value="category"><?php echo $text_category ?></option>';
        html += '        <option value="product"><?php echo $text_featured ?></option>';
        html += '        <option value="bestseller"><?php echo $text_bestseller ?></option>';
        html += '        <option value="latest"><?php echo $text_latest ?></option>';
        html += '        <option value="special"><?php echo $text_special ?></option>';
        html += '      </select></td>';
        html += '    </tr>';
        html += '    <tr class="event-category" id="cate-' + tab_key + '">';
        html += '      <td><?php echo $entry_category; ?></td>';
        html += '      <td><select name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][category_id]">';
        <?php foreach ($categories as $category) { ?>
        html += '           <option value="<?php echo $category['category_id']; ?>">' + <?php echo $this->jsEncode($category['name']); ?> + '</option>';
        <?php } ?>
        html += '      </select></td>';
        html += '    </tr>';

        html += '    <tr class="event-product" id="product-' + tab_key + '">';
        html += '      <td><?php echo $entry_product; ?></td>';
        html += '      <td><input type="text" value="" size="40" /></td>';
        html += '    </tr>';
        html += '    <tr class="event-product-list" id="product-list-' + tab_key + '">';
        html += '      <td>&nbsp;</td>';
        html += '      <td><div id="event-product-' + tab_key + '" class="scrollbox"></div><input type="hidden" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][products]" value=""></td>';
        html += '    </tr>';

        html += '    <tr class="event-limit">';
        html += '      <td><?php echo $entry_item; ?></td>';
        html += '      <td><input type="text" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][item]" value="5" size="3" /></td>';
        html += '    </tr>';
        html += '    <tr>';
        html += '      <td><?php echo $entry_limit; ?></td>';
        html += '      <td><input type="text" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][limit]" value="5" size="3" /></td>';
        html += '    </tr>';
        html += '    <tr>';
        html += '      <td><?php echo $entry_dimension; ?></td>';
        html += '      <td><input type="text" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][image_width]" value="155" size="5" placeholder="width" />';
        html += '      <input type="text" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][image_height]" value="155" size="5" placeholder="height" /></td>';
        html += '    </tr>';

        html += '    <tr>';
        html += '      <td>Product Name</td>';
        html += '      <td width="10"><div class="kuler-switch-btn">';
        html += '        <input type="hidden" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][name]" value="0" />';
        html += '        <input type="checkbox" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][name]" value="1" checked="checked" />';
        html += '        <span class="kuler-switch-btn-holder"></span></div></td>';
        html += '    </tr>';

        html += '    <tr>';
        html += '      <td>Product Price</td>';
        html += '      <td width="10"><div class="kuler-switch-btn">';
        html += '        <input type="hidden" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][price]" value="0" />';
        html += '        <input type="checkbox" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][price]" value="1" checked="checked" />';
        html += '        <span class="kuler-switch-btn-holder"></span></div></td>';
        html += '    </tr>';

        html += '    <tr>';
        html += '      <td>Product Rating</td>';
        html += '      <td width="10"><div class="kuler-switch-btn">';
        html += '        <input type="hidden" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][rating]" value="0" />';
        html += '        <input type="checkbox" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][rating]" value="1" checked="checked" />';
        html += '        <span class="kuler-switch-btn-holder"></span></div></td>';
        html += '    </tr>';

        html += '    <tr>';
        html += '      <td>Product Description</td>';
        html += '      <td width="10"><div class="kuler-switch-btn">';
        html += '        <input type="hidden" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][description]" value="0" />';
        html += '        <input type="checkbox" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][description]" value="1" checked="checked" />';
        html += '        <span class="kuler-switch-btn-holder"></span></div></td>';
        html += '    </tr>';

        html += '    <tr>';
        html += '      <td>Product Add to Card</td>';
        html += '      <td width="10"><div class="kuler-switch-btn">';
        html += '        <input type="hidden" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][add]" value="0" />';
        html += '        <input type="checkbox" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][add]" value="1" checked="checked" />';
        html += '        <span class="kuler-switch-btn-holder"></span></div></td>';
        html += '    </tr>';

        html += '    <tr>';
        html += '      <td>Product Wishlist</td>';
        html += '      <td width="10"><div class="kuler-switch-btn">';
        html += '        <input type="hidden" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][wishlist]" value="0" />';
        html += '        <input type="checkbox" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][wishlist]" value="1" checked="checked" />';
        html += '        <span class="kuler-switch-btn-holder"></span></div></td>';
        html += '    </tr>';

        html += '    <tr>';
        html += '      <td>Product Compare</td>';
        html += '      <td width="10"><div class="kuler-switch-btn">';
        html += '        <input type="hidden" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][compare]" value="0" />';
        html += '        <input type="checkbox" name="kuler_slides_module[' + module_row + '][tabs][' + tab_row +  '][compare]" value="1" checked="checked" />';
        html += '        <span class="kuler-switch-btn-holder"></span></div></td>';
        html += '    </tr>';

	    html += '    <tr>';
	    html += '        <td>Product Description Limit:</td>';
	    html += '        <td>';
	    html += '            <input type="text" name="kuler_slides_module['+ module_row +'][tabs]['+ tab_row +'][description_limit]" size="5" />';
	    html += '        </td>';
	    html += '    </tr>';

        html += '  </table>';
        html += '  </div>';
        html += '</div>';

        $('#form').append(html);

        $('.module-add').before('<a href="#tab-module-' + module_row + '" id="module-' + module_row + '"><?php echo $text_prefix ?> ' + module_row + '&nbsp;<img class="remove-element" src="view/kulercore/images/icons/icon-delete.png" alt="" onclick="$(\'.vtabs a:first\').trigger(\'click\'); $(\'#module-' + module_row + '\').remove(); $(\'#tab-module-' + module_row + '\').remove(); return false;" /></a>');

        $('#product-' + tab_key).hide();
        $('#product-list-' + tab_key).hide();

        $('.vtabs a').click(function() {
            $('#tab').val($(this).attr('href'));
        }).tabs();

        $('#module-' + module_row).trigger('click');

        setTabAutocomplete(module_row, tab_row);

        module_count[module_row] = 2;
        module_row++;
    }

    function changeTabType(obj, module, tab) {
        var type = $(obj).val();
        var key = module + '-' + tab;

        if(type == 'category') {
            $('#cate-' + key).show();
            $('#product-' + key).hide();
            $('#product-list-' + key).hide();
            $('#product-list-' + key + ' .scrollbox').html('');
            $('#product-list-' + key + ' input').val('');
        } else if(type == 'product') {
            $('#cate-' + key).hide();
            $('#product-' + key).show();
            $('#product-list-' + key).show();
        } else {
            $('#cate-' + key).hide();
            $('#product-' + key).hide();
            $('#product-list-' + key).hide();
        }
    }

    function setTabAutocomplete(module, tab) {
        var key = module + '-' + tab;
        $('#product-' + key + ' input').autocomplete({
            delay: 500,
            source: function(request, response) {
                $.ajax({
                    url: 'index.php?route=module/kuler_slides/autocomplete&store_id=<?php echo $selected_store_id; ?>&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request.term),
                    dataType: 'json',
                    success: function(json) {
                        if (json.length == 0) {
                            json.push({
                                name: "<?php echo $text_no_result ?>",
                                product_id: 0
                            });
                        }
                        response($.map(json, function(item) {
                            return {
                                label: item.name,
                                value: item.product_id
                            }
                        }));
                    }
                });
            },
            select: function(event, ui) {
                $('#product-' + key + ' input').val('');

                if(ui.item.value == 0) {
                    return false;
                }

                $('#event-product-' + key + '-' + ui.item.value).remove();

                $('#event-product-' + key).append('<div id="event-product-' + key + '-' + ui.item.value + '">' + ui.item.label + '<img src="view/kulercore/images/icons/icon-delete.png" alt="" /><input type="hidden" value="' + ui.item.value + '" /></div>');

                $('#event-product-' + key + ' div:odd').attr('class', 'odd');
                $('#event-product-' + key + ' div:even').attr('class', 'even');

                data = $.map($('#event-product-' + key + ' input'), function(element){
                    return $(element).attr('value');
                });

                $('#event-product-' + key).next().attr('value', data.join());

                $('#event-product-' + key + '-' + ui.item.value + ' img').click(function() {
                    $(this).parent().remove();

                    $('#event-product-' + key + ' div:odd').attr('class', 'odd');
                    $('#event-product-' + key + ' div:even').attr('class', 'even');

                    data = $.map($('#event-product-' + key + ' input'), function(element){
                        return $(element).attr('value');
                    });

                    $('#event-product-' + key).next().attr('value', data.join());
                });

                return false;
            },
            focus: function(event, ui) {
                return false;
            }
        });
    }

    // Hide all product ajax select
    $('.tab-bestseller .event-category, .tab-latest .event-category, .tab-special .event-category').hide();
    $('.tab-bestseller .event-product, .tab-latest .event-product, .tab-special .event-product').hide();
    $('.tab-bestseller .event-product-list, .tab-latest .event-product-list, .tab-special .event-product-list').hide();

    $('.tab-category .event-product').hide();
    $('.tab-category .event-product-list').hide();
    $('.tab-product .event-category').hide();
    // Ajax request hook for module product
    $('.event-product input').each(function() {
        var row = parseInt($(this).attr('data-row'));
        var tab = parseInt($(this).attr('data-tab'));
        setTabAutocomplete(row, tab);
    });
    // Event for img remove
    $('.tab-product .event-product-list img').each(function() {
        var row = $(this).attr('data-row');
        var pid = $(this).next().val();
        $('#event-product-' + row + '-' + pid + ' img').click(function() {
            $(this).parent().remove();

            $('#event-product-' + row + ' div:odd').attr('class', 'odd');
            $('#event-product-' + row + ' div:even').attr('class', 'even');

            data = $.map($('#event-product-' + row + ' input'), function(element){
                return $(element).attr('value');
            });

            $('#event-product-' + row).next().attr('value', data.join());
        });
    });

    // Created Vtab
    $('.vtabs a').click(function() {
        $('#tab').val($(this).attr('href'));
    }).tabs();

    <?php if ($vtab) { ?>
    $('.vtabs a[href="<?php echo $vtab ?>"]').click();
    <?php } ?>

    (function () {
	    var moduleName = '<?php echo $moduleName; ?>';

	    function generateShortCode(moduleName, moduleTitle) {
		    var shortcode;

		    moduleName = moduleName.toLowerCase();
		    moduleTitle = moduleTitle.toLowerCase();

		    moduleTitle = moduleTitle.replace(/\s+/g, '_');

		    return '[' + moduleName + ' ' + moduleTitle + ']';
	    }

	    // Update the short code when the module title change
	    $('#content').on('keyup change', '.ModuleTitle', function () {
		    $($(this).data('shortcode')).val(generateShortCode(moduleName, this.value));
	    });

	    // Select the shortcode when focus
	    $('#content').on('click', '.ModuleShortCode', function () {
		    this.select();
	    });

	    $('.ModuleTitle').trigger('change');
    })();

    /* Kuler Site Builder */
    <?php if (isset($ksb_trigger_creation) && $ksb_trigger_creation) { ?>
    (function () {
        $('.add-element').trigger('click');
    })();
    <?php } ?>
    //--></script>
<?php echo $footer; ?>